package com.katze.boot.hadoop.service;

import com.katze.boot.hadoop.entity.HadoopEntity;
import com.katze.common.Message;
import org.springframework.core.io.Resource;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.service.annotation.DeleteExchange;
import org.springframework.web.service.annotation.GetExchange;
import org.springframework.web.service.annotation.HttpExchange;
import org.springframework.web.service.annotation.PostExchange;

@HttpExchange("hadoop")
public interface FeignHadoopService {

    @GetExchange(value = "/list")
    Message list(@RequestParam("path") String path, @RequestParam(value = "status", required = false) String status);

    @PostExchange(value = "/{method}")
    Message post(@PathVariable("method") String method, @RequestBody HadoopEntity entity);

    @DeleteExchange(value = "/delete")
    Message delete(@RequestParam("path") String path);

    @PostExchange(value = "/upload", contentType = MediaType.MULTIPART_FORM_DATA_VALUE)
    Message upload(@RequestPart("file") MultipartFile file, @RequestParam("target") String path);

    @GetExchange(value = "/pull")
    ResponseEntity<Resource> download(@RequestParam("path") String path);
}
